<?php
// UltraMemo Project - Quiz_ShowQuestion.php  --
//    queries google doc spreadsheet and displays qusetion
//    included from Quiz.php
//
// 11/16/09 initial creation - Scott Szretter

require_once("Quiz_GetWkShtListFeed.php"); //function to get question from gdoc spreadsheet

//get the questions that need to be reviewed
$GData->GDataQueryString=('nextreviewdt<='.date("m/d/Y 23:59:59"));
$listFeed=$GData->getWkshtListFeed();

//yes, we have at least one
if ( count($listFeed->entries) > 0) {
//get the first row
    $row = $listFeed->entries[0];

    if(is_object($row)) {
        $GData->QuestionsAvailable = TRUE;
        $rowData = $row->getCustom();
        foreach($rowData as $customEntry) {  //loop columns
            if ($customEntry->getColumnName()=="question") {
                $question = $customEntry->getText();
                echo "<p>".$question."</p>";
            } // if customentry = question
            if ($customEntry->getColumnName()=="hint") {
                $hint = $customEntry->getText();
                if(strlen($hint)>0) {
                    ?>
<hr>
<a href="#" onClick="javascript:hint.style.display=''">show hint</a><br><div id="hint" style="display:none"><?=$hint?></div>
                <?
                } //strlen $hint
            } // if customentry = hint
            if ($customEntry->getColumnName()=="answer") {
                $answer = $customEntry->getText();
                if(strlen($answer)>0) {
                    ?>
<hr>
<a href="#" onClick="javascript:answer.style.display=''">show answer</a><br><div id="answer" style="display:none"><?=$answer?></div>
                <?
                } //strlen $answer
            } // if customentry = user
            if ($customEntry->getColumnName()=="qid") {
                $qid = $customEntry->getText();
            } // if column = qid
        } //foreach customentry (columns)


        // we must have a question id!
        if(strlen($qid)>0) {
            ?>
<p>Did you have the correct answer?
    <a href="Quiz.php?ans=1&qid=<?=$qid?>">YES</a><br>
    <a href="Quiz.php?ans=0&qid=<?=$qid?>">NO</a><br>
</p>


        <?
        } // if strlen qid > 0
    } // if is object $row
    else
    {
        $GData->QuestionsAvailable=FALSE;

    }
} // if count listfeed
else
{
    $GData->QuestionsAvailable=FALSE;
}

if($GData->QuestionsAvailable==FALSE)
{
    echo "No questions, good job.";
}
?>